package com.laoyao.validate;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class VideoValidate extends Validator {

	@Override
	protected void validate(Controller c) {

		setShortCircuit(true);
		validateRequired("title", "msg", "标题不能为空");
		validateRequired("type", "msg", "类型不能为空");
		validateRequired("coverPhoto", "msg", "封面不能为空");
		
		if(getActionMethod().getName().equals("add"))
			validateRequired("video", "msg", "视频不能为空");
		
		validateRequired("type1Id", "msg", "一级分类不能为空");
		validateRequired("type2Id", "msg", "二级分类不能为空");
		
		
	}

	@Override
	protected void handleError(Controller c) {
		c.renderJson();		
	}

}
